package com.itqf.dao.impl;

import com.itqf.dao.CategoryDao;
import com.itqf.pojo.Category;
import com.itqf.utils.C3P0Utils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * projectName: gpshop
 *
 * @author: 赵伟风
 * time: 2021/7/22 15:01
 * description:
 */
public class CategoryDaoImpl implements CategoryDao {

    /**
     * 查询数据库类别方法
     *
     * @return
     */
    @Override
    public List<Category> queryAll() throws SQLException {

        String sql = "select c_id cId,c_name cName,c_info cInfo from catetory;";

        QueryRunner queryRunner = new QueryRunner(C3P0Utils.getDataSource());

        List<Category> categoryList = queryRunner.query(sql, new BeanListHandler<>(Category.class));

        return categoryList;
    }
}
